package com.ruoyi.web.dorm.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.web.dorm.entity.VisitorEntity;
import com.ruoyi.web.dorm.mapper.VisitorMapper;
import com.ruoyi.web.dorm.service.VisitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VisitorServiceImpl implements VisitorService {
    @Autowired
    private VisitorMapper visitorMapper;
    /*
     * 获取访客信息
     * */
    @Override
    public List<VisitorEntity> getVisitor(VisitorEntity visitorEntity) {
        return visitorMapper.getVisitor(visitorEntity);
    }

    /**
     * 添加访客记录
     * @param visitorEntity
     * @return
     */
    @Override
    public int addVisitor(VisitorEntity visitorEntity) {
        String username = SecurityUtils.getLoginUser().getUsername(); //获取创建人的名字 添加进去
        visitorEntity.setCreateBy(username);
        return visitorMapper.addVisitor(visitorEntity);
    }
}
